package com.yunti.business.utils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;

public class LotteryUtil {

    public static int lottery(int size, List<Integer> bhList){
        List<Integer> numList = new ArrayList<>();
        for (int i = 1; i <= size ; i++) {
            numList.add(i);
        }
        numList = numList.stream().filter(new Predicate<Integer>() {
            @Override
            public boolean test(Integer integer) {
                return !bhList.contains(integer);
            }
        }).collect(Collectors.toList());
        Collections.shuffle(numList);
        return numList.get(0);
    }

    public static int lottery(int size, int start,List<Integer> bhList){
        List<Integer> numList = new ArrayList<>();
        for (int i = 1; i <= size ; i++) {
            numList.add(i + start);
        }
        numList = numList.stream().filter(new Predicate<Integer>() {
            @Override
            public boolean test(Integer integer) {
                return !bhList.contains(integer);
            }
        }).collect(Collectors.toList());
        Collections.shuffle(numList);
        return numList.get(0);
    }
}
